home *** CD-ROM | disk | FTP | other *** search
File List | 1991-09-16 | 4.7 KB | 113 lines |
- Microsoft (R) Macro Assembler Version 5.10 9/16/91 19:16:35
- ZERO FLAGS ; Set display tab to 8 characters Page 1-1
-
-
- 1 PAGE ,132 ; 80 for narrow printers
- 2 TITLE ZERO FLAGS ; Set display tab to 8 characters
- 3 COMMENT *
- 4
- 5 Given the base address of a flag word and the number of bits it contains,
- 6 this function will set all the bits in the flag word to zero (Note that it works
- 7 in byte increments) The program zeros nothing if no bits are defined, allowing
- 8 it to be used with a variable. It is not designed to work with negative bit counts.
- 9
- 10 Programmed By: A. L. Bender, M. D.
- 11 Bender Consulting
- 12 PO Box 8685
- 13 Woodcliff Lake, NJ 07675
- 14
- 15 Not copyright, freely in public domain.
- 16 Not responsible for your use or misuse of this program.
- 17
- 18 This program was tested with Microsoft c 5.1. It demonstrates how the bits
- 19 are stored in a word. The enclosed driver program shows how to call it and
- 20 how to test it. Assumes direction flag is set to FORWARD. (An ok MSC 5.1
- 21 Assumption)
- 22
- 23 The primary purpose of this program is instructional, you can hopefully learn
- 24 something about MASM 5.1 Programming from this, especially how to use the
- 25 higher level language interface. See Microsoft MASM 5.1 Update.
- 26
- 27 Note: This will not execute on an 8086/88 but requires at least an 80186 or V20
- 28 You can remove the .186 statement to get it going on the 8086/88 if you need to
- 29
- 30 The masm call line needs /Dmemmodel={SMALL|MEDIUM|COMPACT|LARGE} as the case
- 31 may be to write the proper code.
- 32 Example:
- 33 masm /Dmemmodel=SMALL /Mx flgzero,,,; Makes a small model flgzero
- 34
- 35
- 36 *
- 37 .186 ; Set processor required
- 38 IFDEF memmodel ; Did user define it?
- 39 % .MODEL memmodel,c ; Use user definition
- 40 ENDIF
- 41 .CODE ;Large Model C Program
- 42 0000 flgzero PROC flagword:PTR BYTE, nrbits:WORD ; Prologue
- 43 0004 8B 46 0A MOV AX,nrbits ; Get Bit count
- 44 0007 85 C0 TEST AX,AX ; If bits are defined (Non Degenerat
- ive Case)
- 45 0009 74 0F JZ @F ; don't get out
- 46 000B 48 DEC AX ; Make count 0...7
- 47 IF @Cpu NE 0
- 48 000C C1 F8 03 SAR AX,3 ; Divide by 8 The easy way
- 49 ENDIF
- 50 000F 33 C9 XOR CX,CX ; Prep CX for later
- 51 0011 40 INC AX ; Insure fraction of byte is ok
- 52 0012 91 XCHG CX,AX ; Copy Quotient of 8 to CX And Zero
- To AX
- Microsoft (R) Macro Assembler Version 5.10 9/16/91 19:16:35
- ZERO FLAGS ; Set display tab to 8 characters Page 1-2
-
-
- 53 0013 57 PUSH DI ; Preserve DI from certain ruin
- 54 IF @Datasize EQ 1 ;
- 55 0014 C4 7E 06 LES DI,flagword ; Get the base address for large dat
- a
- 56 ENDIF
- 57 0017 F3/ AA REP STOSB ; Zero the bytes (See assumption)
- 58 0019 5F POP DI ; Return DI to prior state
- 59 001B CB @@: RET ; Return to user program
- 60 001C flgzero ENDP ; Epilogue
- 61 END ; Epitaph
- Microsoft (R) Macro Assembler Version 5.10 9/16/91 19:16:35
- ZERO FLAGS ; Set display tab to 8 characters Symbols-1
-
-
- Segments and Groups:
-
- N a m e Length Align Combine Class
-
- DGROUP . . . . . . . . . . . . . GROUP
- _DATA . . . . . . . . . . . . 0000 WORD PUBLIC 'DATA'
- FLGZERO_TEXT . . . . . . . . . . 001C WORD PUBLIC 'CODE'
-
- Symbols:
-
- N a m e Type Value Attr
-
- FLAGWORD . . . . . . . . . . . . TEXT DWORD PTR [BP]+6
- flgzero . . . . . . . . . . . . F PROC 0000 FLGZERO_TEXT Global Length = 001C
-
- MEMMODEL . . . . . . . . . . . . TEXT LARGE
-
- NRBITS . . . . . . . . . . . . . TEXT WORD PTR [BP]+10
-
- @0 . . . . . . . . . . . . . . . L NEAR 001A FLGZERO_TEXT
- @CODE . . . . . . . . . . . . . TEXT flgzero_TEXT
- @CODESIZE . . . . . . . . . . . TEXT 1
- @CPU . . . . . . . . . . . . . . TEXT 259
- @DATASIZE . . . . . . . . . . . TEXT 1
- @FILENAME . . . . . . . . . . . TEXT flgzero
- @VERSION . . . . . . . . . . . . TEXT 510
-
-
- 68 Source Lines
- 68 Total Lines
- 23 Symbols
-
- 47034 + 391843 Bytes symbol space free
-
- 0 Warning Errors
- 0 Severe Errors
-